package com.hlyj.http.base.tool.lib_hlyj_base.bean;

import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;

import java.util.ArrayList;
import java.util.List;

public class OrderListBean implements Parcelable {
    private Integer code;
    private String msg;
    private List<DataDTO> data;

    public OrderListBean() {
    }

    protected OrderListBean(Parcel in) {
        if (in.readByte() == 0) {
            code = null;
        } else {
            code = in.readInt();
        }
        msg = in.readString();
        data = in.createTypedArrayList(DataDTO.CREATOR);
    }

    public static final Creator<OrderListBean> CREATOR = new Creator<OrderListBean>() {
        @Override
        public OrderListBean createFromParcel(Parcel in) {
            return new OrderListBean(in);
        }

        @Override
        public OrderListBean[] newArray(int size) {
            return new OrderListBean[size];
        }
    };

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public List<DataDTO> getData() {
        return data;
    }

    public void setData(List<DataDTO> data) {
        this.data = data;
    }

    @NonNull
    @Override
    public String toString() {
        return "OrderListBean{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", data=" + (data != null ? data.toString() : "null") +
                '}';
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        if (code == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeInt(code);
        }
        dest.writeString(msg);
        dest.writeTypedList(data);
    }

    public static class DataDTO implements Parcelable {
        private String imgUrl;
        private String company;
        private String no;
        public String status_detail;
        public String status_desc;
        private List<ListDTO> list;
        private boolean isAd = false;

        public DataDTO() {
        }

        protected DataDTO(Parcel in) {
            imgUrl = in.readString();
            company = in.readString();
            no = in.readString();
            status_detail = in.readString();
            status_desc = in.readString();
            list = in.createTypedArrayList(ListDTO.CREATOR);
            isAd = in.readByte() != 0;
        }

        public static final Creator<DataDTO> CREATOR = new Creator<DataDTO>() {
            @Override
            public DataDTO createFromParcel(Parcel in) {
                return new DataDTO(in);
            }

            @Override
            public DataDTO[] newArray(int size) {
                return new DataDTO[size];
            }
        };

        public boolean isAd() {
            return isAd;
        }

        public void setAd(boolean ad) {
            isAd = ad;
        }

        public String getImgUrl() {
            return imgUrl;
        }

        public void setImgUrl(String imgUrl) {
            this.imgUrl = imgUrl;
        }

        public String getCompany() {
            return company;
        }

        public void setCompany(String company) {
            this.company = company;
        }

        public String getNo() {
            return no;
        }

        public void setNo(String no) {
            this.no = no;
        }

        public String getStatusDetail() {
            return status_detail;
        }

        public void setStatusDetail(String statusDetail) {
            this.status_detail = statusDetail;
        }

        public String getStatusDesc() {
            return status_desc;
        }

        public void setStatusDesc(String statusDesc) {
            this.status_desc = statusDesc;
        }

        public List<ListDTO> getList() {
            return list;
        }

        public void setList(List<ListDTO> list) {
            this.list = list;
        }

        @NonNull
        @Override
        public String toString() {
            return "DataDTO{" +
                    "imgUrl='" + imgUrl + '\'' +
                    ", company='" + company + '\'' +
                    ", isAd='" + isAd + '\'' +
                    ", no='" + no + '\'' +
                    ", statusDetail='" + status_detail + '\'' +
                    ", statusDesc='" + status_desc + '\'' +
                    ", list=" + (list != null ? list.toString() : "null") +
                    '}';
        }

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeString(imgUrl);
            dest.writeString(company);
            dest.writeString(no);
            dest.writeString(status_detail);
            dest.writeString(status_desc);
            dest.writeTypedList(list);
            dest.writeByte((byte) (isAd ? 1 : 0));
        }

        public static class ListDTO implements Parcelable {
            private String datetime;
            private String remark;

            public ListDTO() {
            }

            protected ListDTO(Parcel in) {
                datetime = in.readString();
                remark = in.readString();
            }

            public static final Creator<ListDTO> CREATOR = new Creator<ListDTO>() {
                @Override
                public ListDTO createFromParcel(Parcel in) {
                    return new ListDTO(in);
                }

                @Override
                public ListDTO[] newArray(int size) {
                    return new ListDTO[size];
                }
            };

            public String getDatetime() {
                return datetime;
            }

            public void setDatetime(String datetime) {
                this.datetime = datetime;
            }

            public String getRemark() {
                return remark;
            }

            public void setRemark(String remark) {
                this.remark = remark;
            }

            @Override
            public String toString() {
                return "ListDTO{" +
                        "datetime='" + datetime + '\'' +
                        ", remark='" + remark + '\'' +
                        '}';
            }

            @Override
            public int describeContents() {
                return 0;
            }

            @Override
            public void writeToParcel(Parcel dest, int flags) {
                dest.writeString(datetime);
                dest.writeString(remark);
            }
        }
    }
}